import request from '@/axios'

function formatRequestUri(name) {
  return 'flow/app/' + name
}

export function Add(data) {
  return request.post({
    url: formatRequestUri('Add'),
    data
  })
}
export function Set(id, data) {
  return request.post({
    url: formatRequestUri('Set'),
    data: {
      Id: id,
      Value: data
    }
  })
}
export function Get(id) {
  return request.get({
    url: formatRequestUri('Get'),
    params: {
      id
    }
  })
}

export function Delete(id) {
  return request.get({
    url: formatRequestUri('Delete'),
    params: {
      id
    }
  })
}

export function Enable(id) {
  return request.get({
    url: formatRequestUri('Enable'),
    params: {
      id
    }
  })
}

export function Stop(id) {
  return request.get({
    url: formatRequestUri('Stop'),
    params: {
      id
    }
  })
}
export function Query(query, paging) {
  return request.post({
    url: formatRequestUri('Query'),
    data: {
      Query: query,
      Index: paging.Index,
      Size: paging.Size,
      SortName: paging.SortName,
      IsDesc: paging.IsDesc
    }
  })
}

export function SetFlow(id, data) {
  return request.post({
    url: formatRequestUri('SetFlow'),
    data: {
      Id: id,
      Value: data
    }
  })
}

export function GetList(appType) {
  return request.get({
    url: formatRequestUri('GetList'),
    params: {
      appType
    }
  })
}

export function SetSettleForm(id, formId) {
  return request.post({
    url: formatRequestUri('SetSettleForm'),
    data: {
      Id: id,
      Value: formId
    }
  })
}
